# -*- encoding: utf-8 -*-
"""
@File : config
@Time : 2020/6/14 22:47
@Author : lryself
@Version : 1.0
@Contact : lnolvwe@163.com
"""
import datetime
import os
from configparser import ConfigParser

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# 配置文件和数据文件目录
CONFIG_DIR = os.path.join(BASE_DIR, "configs")

CONFIG = ConfigParser()

CONFIG.read(os.path.join(CONFIG_DIR, 'config.conf'), encoding='utf-8')


class Config(object):

    SECTET_KEY = CONFIG['STATIC_CONFIG']['SECRET_KEY']
    # debug模式
    DEBUG = CONFIG.getboolean('STATIC_CONFIG', 'DEBUG')
    SEND_FILE_MAX_AGE = datetime.timedelta(seconds=1)
    # 数据库配置
    DIALECT = CONFIG['DATABASE']['DIALECT']
    DRIVER = CONFIG['DATABASE']['DRIVER']
    USERNAME = CONFIG['DATABASE']['USERNAME']
    PASSWORD = CONFIG['DATABASE']['PASSWORD']
    HOST = CONFIG['DATABASE']['HOST']
    PORT = CONFIG['DATABASE']['PORT']
    DATABASE = CONFIG['DATABASE']['DATABASE']

    SQLALCHEMY_DATABASE_URI = '{}+{}://{}:{}@{}:{}/{}?charset=utf8'.format(DIALECT, DRIVER, USERNAME, PASSWORD, HOST,
                                                                           PORT, DATABASE)

    SQLALCHEMY_TRACK_MODIFICATIONS = CONFIG.getboolean('DATABASE', 'SQLALCHEMY_TRACK_MODIFICATIONS')

    SQLALCHEMY_POOL_SIZE = int(CONFIG['DATABASE']['SQLALCHEMY_POOL_SIZE'])

    SQLALCHEMY_MAX_OVERFLOW = int(CONFIG['DATABASE']['SQLALCHEMY_MAX_OVERFLOW'])

    # 数据库连接配置

    # 表单保护
    # CSRF_ENABLED = True
    SECRET_KEY = "lryself"
